﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Velocity
{
    public delegate void ErrorOccuredArgs(string Message, int Line);

    internal class CodeProvider
    {
        public event ErrorOccuredArgs OnErrorOccured;

        private string VeloCode = string.Empty;
        private string NativeCode = string.Empty;

        public CodeProvider(string Code)
        {
            VeloCode = utilities.PurgeString(Code);
        }

        public void Provide()
        {
            bool wasError = false;
            string[] Lines = VeloCode.Split('\n');
            for (int i = 0; i < Lines.Length; i++)
            {
                if (Lines[i].StartsWith("with"))
                {
                    Exception tempValidate = CodeValidator.ValidateWithSuper(Lines[i]);
                    if (tempValidate == null)
                    {
                        //Code was valid
                        if (!wasError)
                        {
                            
                        }
                    }
                    else
                    {
                        //Code was invalid keep going dont provide code.
                        wasError = true;
                        OnErrorOccured(tempValidate.Message, i + 1);
                    }
                }
            }
        }
    }
}
